<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');
require_once ('../lib/util.php');
require_once ('../../simpletest/autorun.php');
require_once ('../lib/init.php');

class TestETC_generateSignedRequest extends UnitTestCase {
    
    function setUp(){
        global $login_button,$facebook;
        
        //if there is a session, skip code for getting sesseion
        if(isLoggedIn()){
            try{
                $me = getOneself();
            }catch(Exception $e){
                print($login_button);
                exit();
            }
        }
    }
    
    /*
     * TEST FUNCTIONS START
     */
    function test_sr_verification(){
        $signed_request='cyHRTE6LtLYimRpisXhZAtTJG_SFcDGJJ5eDW76V1A4.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyOTI5ODY4MDAsImlzc3VlZF9hdCI6MTI5Mjk4MTAyNiwib2F1dGhfdG9rZW4iOiIxNTM5NTA0Njc5NzgyMDR8Mi42RTBaNl9CazFnbFZtN29lX2RDdFBRX18uMzYwMC4xMjkyOTg2ODAwLTEyNDY3Mjc3MDd8blVQZld2OEpMazEwSExZaEwtYXJyT09lUDY4IiwidXNlciI6eyJsb2NhbGUiOiJlbl9HQiIsImNvdW50cnkiOiJlcyJ9LCJ1c2VyX2lkIjoiMTI0NjcyNzcwNyJ9';
        $data = parse_signed_request($signed_request, "82fd17a5972c84a402f05b59591c2579");
        
        $this->assertNotNull($data);
    }
    
    function test_genSR(){
        global $session;
        $signed_request = generateSignedRequest($session);
        
        $data = parse_signed_request($signed_request, FB_APP_SECRET);
        $this->assertNotNull($data);
    }
}
?>
